package com.hayrullah.cinema.program;

import java.util.Date;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;

import com.hayrullah.cinema.Dao.CustomerDao;
import com.hayrullah.cinema.Dao.MovieDao;
import com.hayrullah.cinema.Dao.SaloonDao;
import com.hayrullah.cinema.Dao.SeansDao;
import com.hayrullah.cinema.Dao.SeatsDao;
import com.hayrullah.cinema.Util.HibernateUtil;
import com.hayrullah.cinema.entity.Customer;
import com.hayrullah.cinema.entity.Movie;
import com.hayrullah.cinema.entity.Saloon;
import com.hayrullah.cinema.entity.Seans;
import com.hayrullah.cinema.entity.Seats;
import com.hayrullah.cinema.entity.Ticket;

public class Driver {

	public static void main(String[] args) {
		SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
		Session session = sessionFactory.openSession();
		Transaction transaction = session.beginTransaction();

		{
			Movie movie = new Movie();
			MovieDao movieDao = new MovieDao();

			movie.setMoviename("Transformers 2");
			movie.setCategory("Action");
			movie.setStartdate(new Date());
			movie.setEnddate(new Date());
			movieDao.save(movie);
		}
		{
			Saloon saloon = new Saloon();
			SaloonDao saloonDao = new SaloonDao();
			saloon.setSeat_count(10);
			saloon.setSaloon_name("Hiber Saloon");
			saloonDao.save(saloon);
		}

		{
			Seans seans = new Seans();
			SeansDao seansDao = new SeansDao();
			seans.setStarttime(new Date());
			seans.setEndtime(new Date());
			seansDao.save(seans);

		}
		{
			Seats seats = new Seats();
			SeatsDao seatsDao = new SeatsDao();
			seats.setSeathall("a");
			seats.setSeatnumber(5);
			seatsDao.save(seats);
		}
		
		{
			Customer customer = new Customer();
			CustomerDao customerDao = new CustomerDao();
			customer.setCustomername("Fred");
			customer.setGender("male");
			customerDao.save(customer);
		}
		
		
		transaction.commit();
		session.close();

	}
}
